/* MarkusCrawler
 *
 * Copyright (C) 2011 by Markus '[mackan]' Hyttinen <mackanhyttinen@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 */


package me.crawler;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.Timestamp;

public abstract class CrawlerItem {
	
	protected int id ;
	protected int depth; 
	protected int parentId;
	protected URL url ;
	protected byte[] content;
	protected Timestamp dateCrawled;
	
	
	
	public CrawlerItem(URL url , byte[] content,int id, int  parentId ,int depth , Timestamp dateCrawled ){	
		this.url = url;
		this.content = content;
		this.id = id;
		this.parentId = parentId;
		this.depth = depth;
		this.dateCrawled = dateCrawled;
	}
	
	public CrawlerItem(URL _url , byte[] _content){	
		url = _url;
		content = _content;
	}
	
	public CrawlerItem(URL _url ){	
		url = _url;
	}

	public CrawlerItem(String _url ){	
		try {
			 url = new URL( _url);
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	/**
	 * @return the id
	 */
	public synchronized int getId() {
		return id;
	}


	/**
	 * @param id the id to set
	 */
	public synchronized void setId(int id) {
		this.id = id;
	}


	/**
	 * @return the depth
	 */
	public synchronized int getDepth() {
		return depth;
	}


	/**
	 * @param depth the depth to set
	 */
	public synchronized void setDepth(int depth) {
		this.depth = depth;
	}


	/**
	 * @return the parentId
	 */
	public synchronized int getParentId() {
		return parentId;
	}


	/**
	 * @param parentId the parentId to set
	 */
	public synchronized void setParentId(int parentId) {
		this.parentId = parentId;
	}


	/**
	 * @return the url
	 */
	public synchronized URL getUrl() {
		return url;
	}


	/**
	 * @param url the url to set
	 */
	public synchronized void setUrl(URL url) {
		this.url = url;
	}


	/**
	 * @return the content
	 */
	public synchronized byte[] getContent() {
		return content;
	}


	/**
	 * @param content the content to set
	 */
	public synchronized void setContent(byte[] content) {
		this.content = content;
	}


	/**
	 * @return the dateCrawled
	 */
	public synchronized Timestamp getDateCrawled() {
		return dateCrawled;
	}


	/**
	 * @param dateCrawled the dateCrawled to set
	 */
	public synchronized void setDateCrawled(Timestamp dateCrawled) {
		this.dateCrawled = dateCrawled;
	}


	public abstract boolean equals (Object  o);
	
	

}
